﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace ZG_member
{
    public partial class CourseStage : Form
    {
        public CourseStage()
        {
            InitializeComponent();
            skinEngine1.SkinFile = Application.StartupPath + ConfigurationManager.AppSettings["Skin"];
            this.Opacity = 0;
        }

        private void CourseStage_Load(object sender, EventArgs e)
        {
            timer1.Start();
            ZG_member.BLL.CourseStage course = new ZG_member.BLL.CourseStage();
            ZG_member.Model.CourseStage courseMode = new ZG_member.Model.CourseStage();
            dataGridView1.DataSource= course.GetListWhere("").Tables[0];
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Left += 2;
            this.Opacity += 0.1;
            if (Opacity == 1)
            {
                this.timer1.Stop();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            this.Top = this.Top + 10;
            this.Opacity = this.Opacity - 0.06;
            if (Opacity <= 0)
            {
                this.timer2.Stop();
                this.Close();
            }
        }
        int flag = 0;
        private void CourseStage_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (flag == 0)
            {
                e.Cancel = true;
                flag = 1;
                this.timer2.Start();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CourseAdd add = new CourseAdd(this);
            add.ShowDialog();
        }

        private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            ZG_member.BLL.CourseStage course = new ZG_member.BLL.CourseStage();
            ZG_member.Model.CourseStage courseMode = new ZG_member.Model.CourseStage();
            int id = Convert.ToInt32(this.dataGridView1.CurrentRow.Cells["Id"].Value);
            courseMode=course.GetModel(id);
            CourseAdd add = new CourseAdd(courseMode, this);
            add.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            ZG_member.BLL.CourseStage course = new ZG_member.BLL.CourseStage();
            ZG_member.Model.CourseStage courseMode = new ZG_member.Model.CourseStage();
            int id = Convert.ToInt32(this.dataGridView1.CurrentRow.Cells["Id"].Value);
            courseMode = course.GetModel(id);
            CourseAdd add = new CourseAdd(courseMode, this);
            add.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ZG_member.BLL.CourseStage course = new ZG_member.BLL.CourseStage();
            ZG_member.Model.CourseStage courseMode = new ZG_member.Model.CourseStage();
            int id = Convert.ToInt32(this.dataGridView1.CurrentRow.Cells["Id"].Value);
            course.Delete(id);
            MessageBox.Show("删除成功");
            dataGridView1.DataSource = course.GetListWhere("").Tables[0];
        }
    }
}
